using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sedna.Core.Controls.Support.Tab
{
    /// <summary>
    /// Handles contents of one page of TabControl.
    /// </summary>
    [ParseChildren(false)]
    public class Tab : WebControl, INamingContainer, ILabelledControl
    {
        private string text = "&nbsp;";
        private string textKey;
        private bool selected;
        private string visibleBindPath;
        private string visibleUnbindPath;
        
        
        public string VisibleBindPath
        {
            get { return visibleBindPath; }
            set { visibleBindPath = value; }
        }

        public string VisibleUnbindPath
        {
            get { return visibleUnbindPath; }
            set { visibleUnbindPath = value; }
        }

        public bool Selected
        {
            get { return selected; }
            set { selected = value; }
        }

        public string TextKey
        {
            get { return textKey; }
            set { textKey = value; }
        }

        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddStyleAttribute("display", selected?"run-in":"none");
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.RenderBeginTag(writer);

            writer.WriteLine("<td class=\"filter\">");

            base.RenderContents(writer);

            writer.WriteLine("</td>");

            base.RenderEndTag(writer);
        }


        public Tab() : base(HtmlTextWriterTag.Tr)
        {
        }
    }
}

